/*
 * WebComponent.java
 *
 * Created on March 26, 2007, 6:04 PM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */
package org.xeerkat.xmpp.server.www;

import java.net.URI;
import java.util.logging.Level;
import org.restlet.Component;
import org.restlet.Server;
import org.restlet.data.Protocol;
import org.xeerkat.xmpp.server.XMPPServer;

/**
 *
 * @author alex
 */
public class AdminComponent extends Component {

   static public String LOG_NAME = "org.xeerkat.xmpp.server.www";
   /** Creates a new instance of WebComponent */
   public AdminComponent(Protocol protocol,String address,int port,URI authService,XMPPServer xmppServer) {
      getLogService().setLoggerName(LOG_NAME);

      getLogger().info("Admin host is "+address+":"+port);
      getServers().add(protocol, "*".equals(address) ? null : address, port);
      
      getDefaultHost().attach(new AdminApplication(getContext().createChildContext(),authService,xmppServer));
      
      // Add the clients
      getClients().add(Protocol.FILE);
      getClients().add(Protocol.HTTP);
      getClients().add(Protocol.HTTPS);

      for (Server server : getServers()) {
         try {
            server.start();
         } catch (Exception ex) {
            getLogger().log(Level.SEVERE,"Cannot start server.",ex);
         }
      }

   }

}
